package org.dromara.visitor.controller;

import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R;
import org.dromara.visitor.domain.dto.OrganizationAddReq;
import org.dromara.visitor.domain.dto.OrganizationResp;
import org.dromara.visitor.service.OrganizationService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 组织表
 */
@RestController
@RequestMapping("/vis/org")
public class OrganizationController {

    @Resource
    private OrganizationService organizationService;

    /**
     * 组织新增修改
     * @param addReq
     * @return
     */
    @PostMapping("/add")
    public R addOrg(@RequestBody OrganizationAddReq addReq){
        organizationService.addOrg(addReq);
        return R.ok();
    }

    /**
     * 组织列表查询
     * @return
     */
    @GetMapping("/list")
    public R<List<OrganizationResp>> queryList(){
        List<OrganizationResp> list = organizationService.queryList();
        return R.ok(list);
    }

    /**
     * 未关联规则组织列表
     * @return
     */
    @GetMapping("/unRuleList")
    public R<List<OrganizationResp>> unRuleList(){
        List<OrganizationResp> list = organizationService.unRuleList();
        return R.ok(list);
    }

    /**
     * 组织删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    public R deleteOrg(@RequestParam("id") Long id){
        organizationService.deleteOrg(id);
        return R.ok();
    }
}
